package InitialRank;

import java.io.IOException;

import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.compress.DefaultCodec;
import org.apache.hadoop.io.compress.GzipCodec;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.RunningJob;
import org.apache.hadoop.mapred.SequenceFileInputFormat;
import org.apache.hadoop.mapred.SequenceFileOutputFormat;

import removeDanglingPage.PartitionConf;

import mapred.CombineConfig;
import mapred.InputConfig;
import mapred.Job;
import mapred.MapConfig;
import mapred.OutputConfig;
import mapred.ReduceConfig;

public class InitialRank extends Job{

	private String input0;
	private String input1;
	private String output;
	
	public InitialRank(String input, String input1, String output) {
		super("InitialRank", new String[0]);
		this.input0 = input;
		this.input1 = input1;
		this.output = output;
	}

	@Override
	protected CombineConfig getCombineConfig() {
		// TODO Auto-generated method stub
		return CombineConfig.newInstance(null);
	}

	@Override
	protected InputConfig getInputConfig(FileSystem fs) throws IOException {
		// TODO Auto-generated method stub
		return InputConfig.newInstance(SequenceFileInputFormat.class, input0, input1);
	}

	@Override
	protected String getLogPath() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected MapConfig getMapConfig() {
		// TODO Auto-generated method stub
		return MapConfig.newInstance(null, 0, BytesWritable.class, BytesWritable.class, DefaultCodec.class);
	}

	@Override
	protected OutputConfig getOutputConfig(FileSystem fs) throws IOException {
		// TODO Auto-generated method stub
		return OutputConfig.newInstance(SequenceFileOutputFormat.class, BytesWritable.class, BytesWritable.class, output, GzipCodec.class);
	}

	@Override
	protected ReduceConfig getReduceConfig() {
		// TODO Auto-generated method stub
		return ReduceConfig.newInstance(InitialRank_Reducer.class, 2000);
	}

	@Override
	protected void setUp(JobConf conf, FileSystem fs) throws IOException {
		// TODO Auto-generated method stub
		conf.setPartitionerClass(PartitionConf.class);
		SequenceFileOutputFormat.setOutputCompressionType(conf, SequenceFile.CompressionType.BLOCK);
	}

	@Override
	protected void tearDown(JobConf conf, FileSystem fs, RunningJob job)
			throws IOException {
		// TODO Auto-generated method stub
		
	}
	
}
